import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

import '../services/api/api_service.dart';
import '../services/storage/local_storage_service.dart';
import '../services/storage/secure_storage_service.dart';
import '../services/auth_service.dart';
import '../services/theme_service.dart';
import '../services/analytics_service.dart';
import '../services/device/connectivity_service.dart';
import '../services/device/permission_service.dart';
import '../../core/network/api_provider.dart';

/// 核心服务绑定类
/// 负责注册和管理核心服务依赖
class CoreBinding implements Bindings {
  @override
  void dependencies() {
    // 确保GetStorage实例已注册
    if (!Get.isRegistered<GetStorage>()) {
      Get.put(GetStorage(), permanent: true);
    }
    
    // 网络服务
    if (!Get.isRegistered<ApiProvider>()) {
      Get.put(ApiProvider(), permanent: true);
    }
    
    if (!Get.isRegistered<ApiService>()) {
      Get.put(ApiService(), permanent: true);
    }
    
    // 存储服务
    if (!Get.isRegistered<LocalStorageService>()) {
      Get.put(LocalStorageService(), permanent: true);
    }
    
    if (!Get.isRegistered<SecureStorageService>()) {
      Get.put(SecureStorageService(), permanent: true);
    }
    
    // 应用服务
    if (!Get.isRegistered<AuthService>()) {
      Get.put(AuthService(), permanent: true);
    }
    
    if (!Get.isRegistered<ThemeService>()) {
      Get.put(ThemeService(), permanent: true);
    }
    
    if (!Get.isRegistered<AnalyticsService>()) {
      Get.put(AnalyticsService(), permanent: true);
    }
    
    // 设备服务
    if (!Get.isRegistered<ConnectivityService>()) {
      Get.put(ConnectivityService(), permanent: true);
    }
    
    if (!Get.isRegistered<PermissionService>()) {
      Get.put(PermissionService(), permanent: true);
    }
  }
} 